﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Input;
using SilentWebsite.Model;
using SilentWebsite.ViewModels.Commands;
using SilentWebsite.Views.Windows;

namespace SilentWebsite.ViewModels.Windows
{
    public class SignInViewModel : ViewModelBase, INotifyDataErrorInfo
    {
        public event EventHandler<DataErrorsChangedEventArgs> ErrorsChanged;
        public bool HasErrors { get; private set; }

        public ICommand SignIn { get; set; }
        public ICommand Cancel { get; set; }

        public string UserName { get; set; }
        public string Password { get; set; }

        private readonly SignInChild signInWindow;

        public SignInViewModel(SignInChild window) : base("Sign In")
        {
            signInWindow = window;
            signInWindow = window;
            SignIn = new SimpleCommand(SignInUser);
            Cancel = new SimpleCommand(signInWindow.Close);
        }

        private void SignInUser()
        {
            SilentEngine.Instance.Authentication.SignIn(UserName, Password);
            signInWindow.Close();
        }

        public IEnumerable GetErrors(string propertyName)
        {
            return new List<object>();
        }
    }
}
